<?php

namespace backend\models;

use Yii;
use yii\db\ActiveRecord;

/**
 * This is the model class for table "brand".
 *
 * @property integer $id
 * @property string $name
 * @property string $logo
 * @property integer $status
 * @property integer $sort
 * @property string $intro
 */
class Brand extends ActiveRecord
{

    public $imginfo;

    public static $statusInfo = [-1=>'删除',0=>'隐藏',1=>'正常'];

    public $identifyCode;
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'brand';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['name','logo','intro','status', 'sort'], 'required'],
            [['status', 'sort'], 'integer'],
            [['intro'], 'string'],
            [['name'], 'string', 'max' => 255],
//            [['imginfo'], 'image','skipOnEmpty'=>false],
//            [['identifyCode'],'captcha'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => '商品品牌名称',
            'logo' => 'LOGO',
            'status' => '状态',
            'sort' => '排序',
            'intro' => '简介',
            'imginfo' => '商标LOGO',
            'identifyCode' => '验证码',
        ];
    }

    /*
     * 处理图片的显示路径
     */
    public function getImgsrc(){
        if(substr($this->logo,0,4)=='http'){
            return $this->logo;
        }else{
            return '@web'.$this->logo;
        }
    }
}
